package com.example.basic.web.controller.log;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.example.basic.core.result.Result;
import com.example.basic.core.result.ResultGenerator;
import com.example.basic.custom.Log;
import com.example.basic.web.response.OperLogResponse;
import com.example.basic.web.service.log.OperLogService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;


@Api(value  = "日志管理", tags = {"日志管理"})
@RestController
@RequestMapping("/api/v1/byg/log")
public class OperLogController {

    @Resource
    private OperLogService operLogService;

    @Log(title = "日志管理", description = "列表")
    @ApiOperation(value = "列表", notes = "列表")
    @PostMapping("/queryList")
    public Result<IPage<OperLogResponse>> queryList(
            @ApiParam(name = "logType", value = "日志类型 1-入库，2-出库，3-库存，4-移位") @RequestParam(required = true) String logType,
            @ApiParam(name = "content", value = "日志内容") @RequestParam(required = false) String content,
            @ApiParam(name = "operPerson", value = "操作人") @RequestParam(required = false) String operPerson,
            @ApiParam(name = "operType", value = "操作类型") @RequestParam(required = false) String operType,
            @ApiParam(name = "beginTime", value = "开始日期") @RequestParam(required = false) String beginTime,
            @ApiParam(name = "endTime", value = "结束日期") @RequestParam(required = false) String endTime,
            @ApiParam(name = "page", value = "页数，list分页的第几页") @RequestParam(defaultValue = "0") Integer page,
            @ApiParam(name = "size", value = "条数，list分页的每页条数") @RequestParam(defaultValue = "0") Integer size) {
        Page<OperLogResponse> queryPage = new Page<>(page,size);
        return ResultGenerator.genSuccessResult(operLogService.queryList(queryPage,content, operPerson,operType,beginTime,endTime,logType));
    }
}
